<?php
declare (strict_types = 1);

namespace app\admin\controller;

use addons\Builder\facade\Builder;
use app\common\model\Mutual;
use app\common\model\Area;
//该文件为自动生成，请按需修改
class Publicity extends Base
{
    //主键，默认为id
    protected string $pk = 'id';

    //主模型
    protected string $model = '\app\common\model\Publicity';

    public function index(): string
    {
       return Builder::Table()
           ->autoStructure($this->model, $this->pk, 'barDemo,200')
           ->addRightButtons(['edit' => ['size' => '60%'], 'delete'])
           ->addTopButtons(['add' => ['size' => '60%'], 'deleteAll'])
           ->fetch();
    }
    public static function getMlist(): array
    {
        $data = [];
        $list = Mutual::where(['status'=>2])->select();
        foreach($list as $v){
            $data[$v->id] = $v->rname;
        }
        return $data;
    }
    public static function getProvince(): array
    {
        $data = [];
        $list = Area::where(['pid'=>0])->select();
        foreach($list as $v){
            $data[$v->id] = $v->name;
        }
        return $data;
    }
}
